var $ = require('../../../utils/helper.js'), that = null
var app = getApp()
Page({
  data: {
   
  },
  onLoad(e) {
    that = this
    let id = e.id
    that.setData({id:id})
  },
  onShow: function () {
    $.check(that)
  },
  onReady: function () {
    that.details()
  },
  init: function () {
    that.details()
  },
  details:function(){
    $.post("api/signup/detail",{user_id:that.data.id},function(data){
      that.setData({info:data})
      console.log(that.data.info.pic[0])
    })
  },
  praise: function () {
    $.post("api/signup/great", { user_id: that.data.id, type: 2 }, function (data) {
      that.init()
    })
  },
  collect: function () {
    $.post("api/signup/collect", { user_id: that.data.id, type: 2 }, function (data) {
      that.init()
    })
  },
   save:function(){
    wx.showLoading({
      title: '正在生成海报',
    })
     let poster_url ="https://yueyixing.beiyii.xyz/api/index/signupposter?id="+that.data.id
    wx.downloadFile({
      url: poster_url, 
      success(res) {
        wx.hideLoading()
        if (res.statusCode === 200) {
          let file = res.tempFilePath
          wx.saveImageToPhotosAlbum({
            filePath:file,
            success:function(){
              getApp().toast("保存海报成功")
            }
          })
        }
      }
    })
  },
  
}) 